//index.js
//获取应用实例
const app = getApp()
var publicFn = require('../../asset.js')
Page({
  data: {
    id:'1',
    // tab切换 
     tabArr: {
       curHdIndex: 0,
       curBdIndex: 0
     }, 
    //banner
    imgUrls: [],
    indicatorDots: false,
    autoplay: false,
    interval: 5000,
    duration: 1000,
    indicatorDots:true,
    //icon图标
    icon:[
      {
        image:"../../images/小程序.png",
        text:"小程序"
      },
      {
        image: "../../images/微信.png",
        text: "微营销"
      },
      {
        image: "../../images/运营.png",
        text: "代运营"
      },
      {
      image: "../../images/问题.png",
      text: "常见问题"
      }
    ],
    iconid:[
      {
        article_id: '1'
      }, {
        article_id: '2'
      }, {
        article_id: '3'
      }, {
        article_id: '4'
      }
      
    ],
    //视频中心
    videos: [
    ],
   //功能中心
   fn: [
     {
       title: "分销系统",
       img_url: "../../images/分销.png"
     },
     {
       title: "储值充值 ",
       img_url: "../../images/储值卡.png"
     },
     {
       title: "拼团商品",
       img_url: "../../images/团购.png"
     },
     {
       title: "秒杀商品",
       img_url: "../../images/秒杀.png"
     },
     {
       title: "外卖系统",
       img_url: "../../images/外卖.png"
     },
     {
       title: "新闻资讯",
       img_url: "../../images/新闻.png"
     },
     {
       title: "个人中心",
       img_url: "../../images/个人.png"
     },
     {
       title: "到店管理",
       img_url: "../../images/店铺.png"
     },
     {
       title: "地图定位",
       img_url: "../../images/地图.png"
     },
     {
       title: "独立商家",
       img_url: "../../images/独立.png"
     },
     {
       title: "数据表单",
       img_url: "../../images/表单.png"
     },
     {
       title: "视频系统",
       img_url: "../../images/视频.png"
     }
   ],
  articelClass:[
    { type: "全部" },
    { type: "营销" },
    { type: "工具", }, 
    { type: "运营",}
  ],
   news: []
  },
  //tab切换
  tab: function (e) {
    //var dataId = e.currentTarget.dataset.id;
    var dataId = e.currentTarget.id;
    var obj = {};
    obj.curHdIndex = dataId;
    obj.curBdIndex = dataId;
    this.setData({
      tabArr: obj
    })
  },

  //to 视频列表
  toVideoList: function () {
    wx.navigateTo({
      url: "../videoList/videoList" 
    })
  },
  //to 功能中心
  tofn: function (e) {
    var til = e.currentTarget.dataset.title;
    var id = e.currentTarget.id;
    wx.navigateTo({
      url: "../fn/fn?title="+til+"&id="+id
    })
  },
  //to 文章
  toArticle:function(e){
    var id = e.currentTarget.id
    wx.navigateTo({
      url: "../article/article?id=" +id
    })
  },
  //事件处理函数
  bindViewTap: function() {
    wx.navigateTo({
      url: '../logs/logs'
    })
  },
  onLoad: function () {
    console.log(publicFn.apisrc)
    wx.setNavigationBarTitle({
      title: '首页'
    })
     wx.request({
       url: publicFn.apisrc+'/web/'+publicFn.companyId+'/sysconfig/homepage/get',
      data: {
      },
      header: {
         'content-type': 'application/json' 
       },
       success:  (res)=> {
       console.log(res)
         this.setData({
          'imgUrls':res.data.ret.banner || [],
          'iconid': res.data.ret.icons || [],
          'videos': res.data.ret.videos || [],
          'news': res.data.ret.news || []
         });
       }
     })
  },
  onReady:function(){
  
  },
  getUserInfo: function(e) {

  }
})
